package whf.framework.meta.entity;


import whf.framework.entity.AbstractEntity;
import whf.framework.util.Utils;

/**
 * @author wanghaifeng
 *
 */
public class AbstractProperty extends AbstractEntity implements IProperty {
	private final static long serialVersionUID = 0;
	
	/**
	 * int等原始类型除外，其它使用java类表示
	 */
	private String dataType;

	/**
	 * 显示标签，如果空则使用label
	 */
	private String displayTitle;

	/**
	 * 显示类型，如果空则使用dataType，
	 */
	private String displayType;

	/**
	 * 显示最大长度
	 */
	private int displayMaxLength;

	/**
	 * the control width
	 */
	private int displayWidth;
	/**
	 * 是否主键
	 */
	private boolean primaryKey;
	
	/**
	 * 数据库列名
	 */
	private String dbColumnName;
	
	/**
	 * sort order
	 */
	private int sortOrder;

	/**
	 * 是否可见
	 */
	private boolean visible = true;
	
	private String maxValue;
	
	private String minValue;
	
	private boolean required;
	
	/**
	 * max length of string property value;
	 */
	private int maxLength;
	
	private String queryString;
	
	private String dictCategoryCode;
	
	private boolean allowMultiRows;
	
	//editable control attributes
	private String htmlAttributes;
	
	//static text functions;
	private String hyperLink;
	
	private String jsFunction;
	
	private int visibleLevel;
	
	private int editableLevel;
	
	private int colspan;
	//
	
	private boolean queryCondition;
	
	private boolean readonly;
	
	private boolean viewObjectDetail;
	
	/**
	 * 是否枚举选项
	 * @property boolean:enumSelections
	 */
	private boolean enumSelections;
	
	private String regexPattern;
	
	private String regexPatternSample;
	
	private String helpContent;
	/**
	 * @return Returns the enumSelections.
	 */
	public boolean isEnumSelections() {
		return enumSelections;
	}

	/**
	 * @param enumSelections The enumSelections to set.
	 */
	public void setEnumSelections(boolean enumSelections) {
		this.enumSelections = enumSelections;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public int getDisplayMaxLength() {
		return displayMaxLength;
	}

	public void setDisplayMaxLength(int displayMaxLength) {
		this.displayMaxLength = displayMaxLength;
	}

	public int getDisplayWidth() {
		return displayWidth;
	}

	public void setDisplayWidth(int displayWidth) {
		this.displayWidth = displayWidth;
	}

	public String getDisplayType() {
		return displayType;
	}

	public void setDisplayType(String displayType) {
		this.displayType = displayType;
	}

	public boolean isPrimaryKey() {
		return primaryKey;
	}

	public void setPrimaryKey(boolean primaryKey) {
		this.primaryKey = primaryKey;
	}

	public String getDbColumnName() {
		return dbColumnName;
	}

	public void setDbColumnName(String dbColumnName) {
		this.dbColumnName = dbColumnName;
	}

	public int getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(int sortOrder) {
		this.sortOrder = sortOrder;
	}

	public String getDisplayTitle() {
		return displayTitle;
	}

	public void setDisplayTitle(String displayTitle) {
		this.displayTitle = displayTitle;
	}
	
	public Class getDataTypeClass(){
		return Utils.getClassByClassName(this.dataType);
	}
	
	public boolean isVisible() {
		return visible;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public boolean isPrimitive(){
		return this.getDataTypeClass() == null;
	}

	public String getMaxValue() {
		if(this.maxValue == null) return "";
		return maxValue;
	}

	public void setMaxValue(String maxValue) {
		this.maxValue = maxValue;
	}

	public String getMinValue() {
		if(this.minValue == null) return "";
		return minValue;
	}

	public void setMinValue(String minValue) {
		this.minValue = minValue;
	}

	public boolean isRequired() {
		return required;
	}

	public void setRequired(boolean required) {
		this.required = required;
	}

	public String getQueryString() {
		return queryString;
	}

	public void setQueryString(String queryString) {
		this.queryString = queryString;
	}
	
	public int getMaxLength() {
		return maxLength;
	}

	public void setMaxLength(int maxLength) {
		this.maxLength = maxLength;
	}

	public boolean isAllowMultiRows() {
		return allowMultiRows;
	}

	public void setAllowMultiRows(boolean allowMultiRows) {
		this.allowMultiRows = allowMultiRows;
	}

	public String getDictCategoryCode() {
		return dictCategoryCode;
	}

	public void setDictCategoryCode(String dictCategoryCode) {
		this.dictCategoryCode = dictCategoryCode;
	}

	public String getHtmlAttributes() {
		return htmlAttributes;
	}

	public void setHtmlAttributes(String htmlAttributes) {
		this.htmlAttributes = htmlAttributes;
	}

	public String getHyperLink() {
		return hyperLink;
	}

	public void setHyperLink(String hyperLink) {
		this.hyperLink = hyperLink;
	}

	public String getJsFunction() {
		return jsFunction;
	}

	public void setJsFunction(String jsFunction) {
		this.jsFunction = jsFunction;
	}

	public int getVisibleLevel() {
		return visibleLevel;
	}

	public void setVisibleLevel(int visibleLevel) {
		this.visibleLevel = visibleLevel;
	}

	public int getEditableLevel() {
		return editableLevel;
	}

	public void setEditableLevel(int editableLevel) {
		this.editableLevel = editableLevel;
	}

	public int getColspan() {
		return colspan;
	}

	public void setColspan(int colspan) {
		this.colspan = colspan;
	}

	public boolean isQueryCondition() {
		return queryCondition;
	}

	public void setQueryCondition(boolean queryCondition) {
		this.queryCondition = queryCondition;
	}

	public boolean isReadonly() {
		return readonly;
	}

	public void setReadonly(boolean readonly) {
		this.readonly = readonly;
	}

	public boolean isViewObjectDetail() {
		return viewObjectDetail;
	}

	public void setViewObjectDetail(boolean viewObjectDetail) {
		this.viewObjectDetail = viewObjectDetail;
	}

	@Override
	public int compareTo(java.lang.Object obj) {
		AbstractProperty property = (AbstractProperty)obj;
		return this.getSortOrder() - property.getSortOrder();
	}

	/**
	 * @return Returns the regexString.
	 */
	public String getRegexPattern() {
		return regexPattern;
	}

	/**
	 * @param regexString The regexString to set.
	 */
	public void setRegexPattern(String regexString) {
		this.regexPattern = regexString;
	}

	/**
	 * @return Returns the regexPatternSample.
	 */
	public String getRegexPatternSample() {
		return regexPatternSample;
	}

	/**
	 * @param regexPatternSample The regexPatternSample to set.
	 */
	public void setRegexPatternSample(String regexPatternSample) {
		this.regexPatternSample = regexPatternSample;
	}

	public String getHelpContent() {
		return helpContent;
	}

	public void setHelpContent(String helpContent) {
		this.helpContent = helpContent;
	}
}
